/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.lidovky.articles.articlesData.jiranova;

import cz.mzk.lidovky.articles.articlesData.ErroneousArticle;
import java.util.List;

/**
 *
 * @author Martin Řehánek (rehan@mzk.cz)
 */
public class ErroneousArticleImpl implements ErroneousArticle {

    private String[] inputData;
    private List<String> errorMessages;

    /**
     * @return the inputData
     */
    public String[] getInputData() {
        return inputData;
    }

    /**
     * @param inputData the inputData to set
     */
    public void setInputData(String[] inputData) {
        this.inputData = inputData;
    }

    /**
     * @return the errorMessages
     */
    public List<String> getErrorMessages() {
        return errorMessages;
    }

    /**
     * @param errorMessages the errorMessages to set
     */
    public void setErrorMessages(List<String> errorMessages) {
        this.errorMessages = errorMessages;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        for (String inputColumn : inputData) {
            builder.append(inputColumn);
            builder.append('\t');
        }

        //note column is missing - because it was empty
        if (inputData.length == 12) {
            builder.append('\t');
        }

        int errorCount = errorMessages.size();
        int messageNumber = 0;
        for (String errorMessage : errorMessages) {
            builder.append(errorMessage);
            if (errorCount > 1 && ++messageNumber < errorCount) {
                builder.append(';');
            }
        }
        return builder.toString();
    }
}
